home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: confusion between putchar and printf
- Date: 11 Mar 1996 15:24 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <11MAR199615245819@erich.triumf.ca>
- References: <4i1v2n$30o@news.azstarnet.com>
- NNTP-Posting-Host: ftp.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <4i1v2n$30o@news.azstarnet.com>, Howard Salmon <captarm@azstarnet.com> writes...
- >K & R (section 1.5) states that "putchar(c) prints the contents of the
- >integer variable c as a character, usually on the screen".
- >
- >Here's a small program that I wrote testing putchar. Why doesn't it
- >compile?
- >
- >#include <stdio.h>
- ># define A "hello world!"
- >
- >main()
- >{
- > int c;
- > c = A;
- > putchar(A);
- >}
-
- Hmmmm - an interesting concept.
-
- What error messages does the compiler give when you try to compile this?
-
- You have defined A to be a string literal. c = A; tries to force a pointer to
- that literal into an int, which is not legal.
-
- If you had said
- c = 'A';
- you would set c equal to the (ASCII) value of the letter 'A', and putchar()
- would print 'A' on the screen.
-
- putchar() prints _only_ one char.
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-
-
-
-